﻿using System.Linq;
using AB.ServiceDirectory.Commons.DataFilters;
using AB.ServiceDirectory.Dao;
using AB.ServiceDirectory.Entities;

namespace AB.ServiceDirectory.BO
{
    /// <summary>
    /// HServiceOrganizationBO
    /// </summary>
    public sealed class HServiceOrganizationBO
    {

        /// <summary>
        /// Prevents a default instance of the <see cref="HServiceOrganizationBO"/> class from being created.
        /// </summary>
        private  HServiceOrganizationBO(){}

        private static readonly HServiceOrganizationDao Dao=new HServiceOrganizationDao();

        /// <summary>
        /// Gets the service organization.
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <param name="sortType">Type of the sort.</param>
        /// <param name="startRowIndex">Start index of the row.</param>
        /// <param name="maxRows">The max rows.</param>
        /// <returns></returns>
        public static IQueryable<ServiceOrganization> GetServiceOrganization(HServiceOrganizationFilter filter, string sortType, int startRowIndex, int maxRows)
        {
            return Dao.GetList(filter, sortType, startRowIndex, maxRows);
        }

        /// <summary>
        /// Gets the serivce organization count.
        /// </summary>
        /// <param name="filter">The filter.</param>
        public static int GetServiceOrganizationCount(HServiceOrganizationFilter filter)
        {
            return Dao.GetListCount(filter);
        }

        /// <summary>
        /// Updates the service organization role.
        /// </summary>
        /// <param name="serviceId">The service id.</param>
        /// <param name="organizationId">The organisation id.</param>
        /// <param name="roles">The roles.</param>
        /// <returns></returns>
        public static  bool  UpdateServiceOrganizationRole(int serviceId, int organizationId, string roles)
        {
            return Dao.UpdateServiceOrganizationRole(serviceId, organizationId, roles);
        }
    }
}
